package com.sskj.mine.presenter;

import com.lzy.okgo.model.Response;
import com.sskj.mine.http.HttpConfig;
import com.sskj.mine.ui.activity.WalletAddressAddActivity;
import com.sskj.common.base.HttpData;
import com.sskj.common.rxbus2.RxBus;
import com.sskj.common.util.ToastUtil;
import com.sskj.lib.RxBusCode;
import com.sskj.lib.http.JsonCallBack;


public class WalletAddressAddActivityPresenter extends BasePresenter<WalletAddressAddActivity> {
    /**
     * 添加钱包地址
     *
     * @param type   类型 ETH 1，BTC 2，BCH 3
     * @param addr   钱包地址
     * @param code   币种码
     * @param remark 备注
     * @return
     */
    public void addWalletAddress(String type, String addr, String code, String remark) {
        httpService.addWalletAddress(type, addr, code, remark)
                .execute(new JsonCallBack<HttpData>(this) {
                    @Override
                    public void onSuccess(Response<HttpData> response) {
                        HttpData httpData = response.body();
                        ToastUtil.showShort(httpData.getMsg());
                        if (httpData.getStatus() == HttpConfig.OK) {
                            RxBus.getDefault().send(RxBusCode.WALLET_LIST_REFRESH);
                            mView.finish();
                        }
                    }
                });
    }
}
